Conditions | 2 |
Total Lines | 74 |
Code Lines | 61 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /** |
||
66 | rangePicker(){ |
||
67 | //Date range picker |
||
68 | $('.input-daterange-datepicker').daterangepicker({ |
||
69 | buttonClasses: ['btn', 'btn-sm'], |
||
70 | applyClass: 'btn-success', |
||
71 | cancelClass: 'btn-light' |
||
72 | }); |
||
73 | $('.input-daterange-timepicker').daterangepicker({ |
||
74 | timePicker: true, |
||
75 | timePickerIncrement: 30, |
||
76 | locale: { |
||
77 | format: 'MM/DD/YYYY h:mm A' |
||
78 | }, |
||
79 | buttonClasses: ['btn', 'btn-sm'], |
||
80 | applyClass: 'btn-success', |
||
81 | cancelClass: 'btn-light' |
||
82 | }); |
||
83 | $('.input-limit-datepicker').daterangepicker({ |
||
84 | format: 'MM/DD/YYYY', |
||
85 | minDate: '06/01/2018', |
||
86 | maxDate: '06/30/2018', |
||
87 | buttonClasses: ['btn', 'btn-sm'], |
||
88 | applyClass: 'btn-success', |
||
89 | cancelClass: 'btn-light', |
||
90 | dateLimit: { |
||
91 | days: 6 |
||
92 | } |
||
93 | }); |
||
94 | |||
95 | $('.reportrange span').html(moment().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + moment().format('MMMM D, YYYY')); |
||
96 | |||
97 | $('.reportrange').daterangepicker({ |
||
98 | format: 'MM/DD/YYYY', |
||
99 | startDate: moment().subtract(29, 'days'), |
||
100 | endDate: moment(), |
||
101 | minDate: '01/01/2017', |
||
102 | maxDate: '12/31/2020', |
||
103 | dateLimit: { |
||
104 | days: 60 |
||
105 | }, |
||
106 | showDropdowns: true, |
||
107 | showWeekNumbers: false, |
||
108 | timePicker: false, |
||
109 | timePickerIncrement: 1, |
||
110 | timePicker12Hour: true, |
||
111 | ranges: { |
||
112 | 'Today': [moment(), moment()], |
||
113 | 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], |
||
114 | 'Last 7 Days': [moment().subtract(6, 'days'), moment()], |
||
115 | 'Last 30 Days': [moment().subtract(29, 'days'), moment()], |
||
116 | 'This Month': [moment().startOf('month'), moment().endOf('month')], |
||
117 | 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] |
||
118 | }, |
||
119 | opens: 'left', |
||
120 | drops: 'down', |
||
121 | buttonClasses: ['btn', 'btn-sm'], |
||
122 | applyClass: 'btn-success', |
||
123 | cancelClass: 'btn-light', |
||
124 | separator: ' to ', |
||
125 | locale: { |
||
126 | applyLabel: 'Submit', |
||
127 | cancelLabel: 'Cancel', |
||
128 | fromLabel: 'From', |
||
129 | toLabel: 'To', |
||
130 | customRangeLabel: 'Custom', |
||
131 | daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], |
||
132 | monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], |
||
133 | firstDay: 1 |
||
134 | } |
||
135 | }, function (start, end, label) { |
||
136 | console.log(start.toISOString(), end.toISOString(), label); |
||
|
|||
137 | $('.reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY')); |
||
138 | }); |
||
139 | } |
||
140 | } |